keymap: Cache key info
authorMatthias Clasen <mclasen@redhat.com>
Thu, 30 Apr 2020 04:33:06 +0000 (00:33 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 30 Apr 2020 17:05:52 +0000 (13:05 -0400)
commit99c3928cecb0bf4dd7c33c1f7fd078b256aa8a78
tree23c25d6f74a4352ccbd3bf6c37d2092a3ad25495
parente5c430266e71289765de6d8bfc40166bcbeff4e7
keymap: Cache key info

We currently calling gdk_display_map_keyval up to
once per key event per shortcut trigger, and that function
does an expensive loop over the entire keymap and
allocates an array. Avoid this by caching the entries
in a single array, and have a lookup table for finding
the entries for a keyval.

To do this, change the GdkKeymap.get_entries_for_keyval
signature, and change the ::keys-changed signal to be
RUN_FIRST, since we want to clear the cache in the class
handler before running signal handlers. These changes are
possible now, since keymaps are no longer public API.
gdk/broadway/gdkkeys-broadway.c
gdk/gdkevents.c
gdk/gdkkeys.c
gdk/gdkkeysprivate.h
gdk/wayland/gdkkeys-wayland.c
gdk/win32/gdkkeys-win32.c
gdk/x11/gdkkeys-x11.c